#ifndef DATATABLE_H
#define DATATABLE_H

#include <QObject>
#include <QVector>

class TableData
{
public:
    TableData(int rows, int cols)
    {
        m_rows = rows;
        m_cols = cols;

        for (int i = 0; i < cols; ++i) {
            QVector<QString> colData(rows);
            m_data.append(colData);
        }
    }

    void setData(int col, int row, const QString& str)
    {
        m_data[col][row] = str;
    }

    QString data(int col, int row) const
    {
        return m_data.at(col).at(row);
    }

    void setName(const QString& name) { m_name = name; }
    QString name() const { return m_name; }

    void setLabels(Qt::Orientation o, const QStringList& labels)
    {
        if (o == Qt::Horizontal)
            m_horizontalLabels = labels;
        else
            m_verticalLabels = labels;
    }

    QStringList labels(Qt::Orientation o)
    {
        if (o == Qt::Horizontal)
            return m_horizontalLabels;
        return m_verticalLabels;
    }

    int rows() const { return m_rows; }
    int cols() const { return m_cols; }

private:
    QString m_name;
    QStringList m_horizontalLabels;
    QStringList m_verticalLabels;
    QVector<QVector<QString> > m_data; // column first
    int m_rows;
    int m_cols;
};
#endif
